local wdtx__jiancaiCardSkill = fk.CreateSkill {
  name = "wdtx__jiancai_skill",
}

local jc_skills = {
  "gongjian","ex__biyue","zuilun","qiangwu","ol_ex__qiangxi","ol_ex__luanji","ty_ex__sanyao","m_ex__xianzhen","ol_ex__jieming",
  "tianyi","mansi","huayi","souying","pingxi","ty_ex__wurong","xuezhao","ty_ex__qingxi","daoshu","ex__longdan","m_ex__mieji",
  "ex__guose","guolun","duliang","os__gongxin","kunfen","ol_ex__jushou","os_ex__bingyi","miji","zhengu","juece","sp__youdi", "kuanshi", "suizheng", "m_ex__jieyue",
  "zhuihuan","os__juchen","ty_ex__jingce","linghui","lueming", "jijie","ty__lianzhu","ex__fanjian","weimeng","poxi","ty__kuangfu","ty_ex__gongqi",
  "ol_ex__tiaoxin","quhu","nuchen","weiwu","m_ex__yanzhu","ty__jianji","changqu","jiuxianc",
}


wdtx__jiancaiCardSkill:addEffect("cardskill", {
  name = "wdtx__jiancai_skill",
  prompt = "#wdtx__jiancai_skill",
  mod_target_filter = Util.TrueFunc,
  can_use = function(self, player, card)
    return not player:isProhibited(player, card)
  end,
  on_use = function(self, room, cardUseEvent)
    if not cardUseEvent.tos or #cardUseEvent.tos == 0 then
      cardUseEvent.tos = { cardUseEvent.from }
    end
  end,
  on_effect = function(self, room, effect)
    local target = effect.to
    if target.dead then return end
    local jiancailv = effect.card:getMark("@jiancailv")
    local newskills = {}
    for _, ski in ipairs(jc_skills) do
      if not target:hasSkill(ski) then
        table.insert(newskills,ski)
      end
    end
    local randchc = table.random(newskills,3+(jiancailv * 2))
    local chs = room:askToChoices(target, {
      choices = randchc,
      min_num = 1+jiancailv,
      max_num = 1+jiancailv,
      skill_name = "#wdtx_rule",
      prompt = "#wdtx_rule",
      cancelable = false,
      detailed = true,
    })
    for _,skill in ipairs(chs) do
      local getskillstr = target:getMark("losejc")
      if getskillstr == 0 then
        local getskill = skill.."|".."#losejcSkill"
        room:setPlayerMark(target,"losejc",skill)
        room:handleAddLoseSkills(target,getskill,nil,false)
      else
        getskillstr = getskillstr.."|"..skill
        room:setPlayerMark(target,"losejc",getskillstr)
        room:handleAddLoseSkills(target,skill,nil,false)
      end
    end
  end
})


return wdtx__jiancaiCardSkill